using System;
using System.Collections;
using System.Collections.Generic;
using System.Reflection;
using System.Runtime.CompilerServices;
using ns16;
using ns20;

namespace Newtonsoft.Json.Serialization
{
	public class JsonDictionaryContract : JsonContainerContract
	{
		private readonly bool bool_7;

		private readonly Type type_3;

		private Type type_4;

		private Delegate3<object, object> delegate3_0;

		private Func<object> func_1;

		[CompilerGenerated]
		private Func<string, string> func_2;

		[CompilerGenerated]
		private Type type_5;

		[CompilerGenerated]
		private Type type_6;

		[CompilerGenerated]
		private JsonContract jsonContract_2;

		[CompilerGenerated]
		private bool bool_8;

		[CompilerGenerated]
		private ConstructorInfo constructorInfo_0;

		public Func<string, string> PropertyNameResolver
		{
			[CompilerGenerated]
			get
			{
				return func_2;
			}
			[CompilerGenerated]
			set
			{
				func_2 = value;
			}
		}

		public Type DictionaryKeyType
		{
			[CompilerGenerated]
			get
			{
				return type_5;
			}
			[CompilerGenerated]
			private set
			{
				type_5 = value;
			}
		}

		public Type DictionaryValueType
		{
			[CompilerGenerated]
			get
			{
				return type_6;
			}
			[CompilerGenerated]
			private set
			{
				type_6 = value;
			}
		}

		internal JsonContract JsonContract_2
		{
			[CompilerGenerated]
			get
			{
				return jsonContract_2;
			}
			[CompilerGenerated]
			set
			{
				jsonContract_2 = value;
			}
		}

		internal bool Boolean_0
		{
			[CompilerGenerated]
			get
			{
				return bool_8;
			}
			[CompilerGenerated]
			private set
			{
				bool_8 = value;
			}
		}

		internal ConstructorInfo ConstructorInfo_0
		{
			[CompilerGenerated]
			get
			{
				return constructorInfo_0;
			}
			[CompilerGenerated]
			private set
			{
				constructorInfo_0 = value;
			}
		}

		public JsonDictionaryContract(Type underlyingType)
			: base(underlyingType)
		{
			enum15_0 = Enum15.Dictionary;
			Type type;
			Type type2;
			if (Class195.smethod_14(underlyingType, typeof(IDictionary<, >), out type_3))
			{
				type = type_3.GetGenericArguments()[0];
				type2 = type_3.GetGenericArguments()[1];
				if (Class195.smethod_12(base.UnderlyingType, typeof(IDictionary<, >)))
				{
					base.CreatedType = typeof(Dictionary<, >).MakeGenericType(type, type2);
				}
			}
			else
			{
				Class195.smethod_19(base.UnderlyingType, out type, out type2);
				if (base.UnderlyingType == typeof(IDictionary))
				{
					base.CreatedType = typeof(Dictionary<object, object>);
				}
			}
			if (type != null && type2 != null)
			{
				ConstructorInfo_0 = Class192.smethod_3(base.CreatedType, typeof(KeyValuePair<, >).MakeGenericType(type, type2));
			}
			Boolean_0 = !typeof(IDictionary).IsAssignableFrom(base.CreatedType);
			DictionaryKeyType = type;
			DictionaryValueType = type2;
			if (DictionaryValueType != null)
			{
				bool_7 = Class195.smethod_10(DictionaryValueType);
			}
		}

		internal Interface16 method_5(object object_0)
		{
			if (delegate3_0 == null)
			{
				type_4 = typeof(Class186<, >).MakeGenericType(DictionaryKeyType, DictionaryValueType);
				ConstructorInfo constructor = type_4.GetConstructor(new Type[1] { type_3 });
				delegate3_0 = Class140.Class167_0.ns20_002EClass167_002E_206A_206E_200E_202E_206E_200B_200B_200E_202C_206A_202A_202B_200C_206A_206C_206D_202B_200F_206E_200F_202C_200D_200D_202B_202B_206F_206D_206E_206D_206B_200B_206B_200B_200E_200D_202E_202A_206C_200F_202B_202E<object>(constructor);
			}
			return (Interface16)delegate3_0(null, object_0);
		}

		internal IDictionary method_6()
		{
			if (func_1 == null)
			{
				Type type = typeof(Dictionary<, >).MakeGenericType(DictionaryKeyType, DictionaryValueType);
				func_1 = Class140.Class167_0.ns20_002EClass167_002E_206E_206D_200F_202C_202B_206A_206E_200E_202B_206A_206F_206A_202E_202C_206E_202D_202A_202D_202B_206F_206C_202D_206C_206C_202A_206E_200B_206A_202A_202C_206B_200C_206A_206A_200B_206D_206A_206E_200E_206E_202E<object>(type);
			}
			return (IDictionary)func_1();
		}
	}
}
